<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload=function(){
            //获取canvas
            var can=document.querySelector('canvas');
            //获取画笔
            var context=can.getContext('2d');
            //设置文字样式
            context.font='bold 32px 楷体';
            //设置水平对齐方式
            context.textAlign='center';
            //设置垂直对齐方式
            context.textBaseline='middle';
            //文字绘制
            context.fillText('蜗牛学院牛逼!',300,300);
        }
    </script>
</head>
<body>
    <canvas style="border:1px solid red" width="600" height="600"></canvas>
</body>
</html>